package com.oocl.ita.manager.controller.manageShop;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.oocl.ita.service.CheckShopService;
import com.oocl.ita.service.ManageShopService;
import com.oocl.ita.service.impl.CheckShopServiceImpl;
import com.oocl.ita.service.impl.ManageShopServiceImpl;
import com.oocl.ita.vo.check.CheckShopModel;

/**
 * Servlet implementation class ShowManageShop
 */
public class ShowManageShop extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ShowManageShop() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		ManageShopService manageShopService = new ManageShopServiceImpl();
		List<CheckShopModel>list  = manageShopService.showManageShop();
		HttpSession httpSession = request.getSession();
		httpSession.setAttribute("shops", list);
		List<Integer> pagingNum = new ArrayList<Integer>();
		for(int i = 1; i < list.size()/10 + 2; i++){
			pagingNum.add(i);
		}
		if(httpSession.getAttribute("begin") == null){
			httpSession.setAttribute("begin", 0);
			httpSession.setAttribute("end", 9);
		}
		httpSession.setAttribute("pagingNum", pagingNum);
		request.getRequestDispatcher("jsp/manageShop.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
